/*
 *  testformecomposee.cpp
 *  Ray Tracing
 *
 *  Created by Jean-Marc Comby + Romain Dequesne on Sat May 01 2004.
 *  Copyright (c) 2004. All rights reserved.
 *
 */

#include "testformecomposee.hpp"

void afficheFC()
{
	Coord origine1(-1,4,2),origine2(1,0,-2);
	VecteurU direction1(0.25,-0.83,-0.5),direction2(-0.424,  0.318, 0.848);
	double R(1),R1(1.5);
	Coord a(0,0,0),b(0,2,0);
	Forme *test1=new Sphere(a,R);
	Forme *test2=new Sphere(b,R1);
	FormeComposee test5(inter,test1,test2);
	FormeComposee *test6=&test5;
	Rayon r1(origine1,direction1);
	Rayon r2(origine2,direction2);
	Coord c1(0, 0.5, 0),c2(0, 0.8, 0),c3(0, 1, 0),c4(0, -1, 0), c5(0, 3.5, 0),c6(0, 0, 1),c7(0, 2, 1.5),c8(0, 1, -2);
	Coord tableauC[8];
	tableauC[0]=c1;
	tableauC[1]=c2;
	tableauC[2]=c3;
	tableauC[3]=c4;
	tableauC[4]=c5;
	tableauC[5]=c6;
	tableauC[6]=c7;
	tableauC[7]=c8;
	Coord c10;
	for (int i(0);i<8;i++)
	{
	std::cout << "Operator = difference" << std::endl;
	std::cout << "Coord : ";
	tableauC[i].affiche();
	std::cout << "isIn" << std::endl;
	std::cout << test6->isIn(tableauC[i]) << std::endl;
	std::cout << "isOn" << std::endl;
	std::cout << test6->isOn(tableauC[i]) << std::endl;
	std::cout << "Normal" << std::endl;
	try
	{
		c10=test6->normale(tableauC[i]);
		std::cout << "Coord : ";
		c10.affiche();
	}
	catch(Erreur& tmp)
	{
		std::cout << "pas de normale possible" << std::endl;
	}
	std::cout << std::endl;
	}
	std::cout << "intersection avec rayon" << std::endl;
	try
	{
		c10=test6->intersect(r1);
		std::cout << "Coord : ";
		c10.affiche();
	}
	catch(Erreur& tmp)
	{
		std::cout << "pas d intersect" << std::endl;
	}
	try
	{
		c10=test6->intersect(r2);
		std::cout << "Coord : ";
		c10.affiche();
	}
	catch(Erreur& tmp)
	{
		std::cout << "pas d intersect" << std::endl;
	}
	delete test1,test2;
}
